#include "qmoviecliptool.h"
#include <QGraphicsSceneMouseEvent>
#include <QGraphicsSceneContextMenuEvent>

QMovieClipTool::QMovieClipTool(QObject *parent)
	: QMyTool(parent)
{

}

QMovieClipTool::~QMovieClipTool()
{

}
void QMovieClipTool::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * mouseEvent)
{
	if(controller->GetNodeType(-1)==MovieClip)
	{
		controller->receiveMessage(new NewNodeMessage(NewNodeArgs(movieClipNode,mouseEvent->scenePos())));
		QString p;
		emit this->getCurrentContainerPath(p);
		QVector<int> path;
		for(int i=0;i!=p.size();i++)
			path.push_back(int(p[i].toAscii()-'0'));
		path.push_back(controller->NumberOfObjects()-1);
		nodePath thepath(path);
		QToolGraphicsScene* scene=new QToolGraphicsScene(0,0,1000,1000);
		scene->SetController(this->controller);
		scene->SetCurrentContainer(thepath);
		this->controller->receiveMessage(new SelectContainerMessage(thepath));
		emit addNewTab(scene,thepath.path);
	}
}
void QMovieClipTool::mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent)
{
}
void QMovieClipTool::mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent)
{
	if(mouseEvent->button()==Qt::RightButton)
	{
		controller->addNode(-1);
	}
}
void QMovieClipTool::mouseReleaseEvent(QGraphicsSceneMouseEvent * mouseEvent)
{
}
void QMovieClipTool::contextMenuEvent(QGraphicsSceneContextMenuEvent * mouseEvent)
{
}